/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wso.global;

import java.util.Calendar;
import java.util.Date;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 *
 * @author Violet_Ink
 */
public class GlobalFunction {
    public static XMLGregorianCalendar ConvertDatetoXMLGregorianCalendar(Date date) throws DatatypeConfigurationException {
        XMLGregorianCalendar xmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
        xmlGregorianCalendar.setDay(date.getDate());
        xmlGregorianCalendar.setMonth(date.getMonth());
        xmlGregorianCalendar.setYear(date.getYear());
        String year = "" + date.getYear();
        String xmldate = xmlGregorianCalendar.toString();
        String month = "" + date.getMonth();
        return xmlGregorianCalendar;
    }

    public static Date ConvertXMLGregorianCalendartoDate(XMLGregorianCalendar xmlDate) {
        Date date = new Date();
        date.setDate(xmlDate.getDay());
        date.setMonth(xmlDate.getMonth());
        date.setYear(xmlDate.getYear());
        return date;
    }
}
